// api方法
const arr = [1,1,2]

function removeDuplicates(nums) {
    let index = 1;
    for (let i = 1; i < nums.length ; i++) {
        if (nums[i] != nums[index - 1]) {
            if (i != index) {
                nums[index] = nums[i];
            }
            index++;
        }
    }
    // let aset = new Set(nums)
    // const array = Array.from(aset);
    return index;
}

console.log(removeDuplicates(arr))
